VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
Begin VB.Form FrmAddCap 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Add Caption and URL Blocking"
   ClientHeight    =   4065
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7005
   Icon            =   "FrmAddCap.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   4065
   ScaleWidth      =   7005
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdedlcap 
      Caption         =   "Delete"
      Height          =   375
      Left            =   1320
      TabIndex        =   7
      Top             =   3600
      Width           =   855
   End
   Begin VB.CommandButton cmdaddcap 
      Caption         =   "Add"
      Height          =   375
      Left            =   120
      TabIndex        =   6
      Top             =   3600
      Width           =   855
   End
   Begin VB.CommandButton cmddelu 
      Caption         =   "Delete"
      Height          =   375
      Left            =   3960
      TabIndex        =   5
      Top             =   3600
      Width           =   1215
   End
   Begin VB.CommandButton cmdaddu 
      Caption         =   "Add"
      Height          =   375
      Left            =   2520
      TabIndex        =   4
      Top             =   3600
      Width           =   1215
   End
   Begin VB.TextBox txturl 
      Height          =   285
      Left            =   2520
      TabIndex        =   3
      Top             =   3240
      Width           =   4335
   End
   Begin VB.TextBox txtcap 
      Height          =   285
      Left            =   120
      TabIndex        =   2
      Top             =   3240
      Width           =   2055
   End
   Begin ComctlLib.ListView lvcap 
      Height          =   2775
      Left            =   120
      TabIndex        =   8
      Top             =   120
      Width           =   2055
      _ExtentX        =   3625
      _ExtentY        =   4895
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      _Version        =   327682
      ForeColor       =   49152
      BackColor       =   0
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   2
      BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "Caption"
         Object.Width           =   2822
      EndProperty
      BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         SubItemIndex    =   1
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "Caption1"
         Object.Width           =   0
      EndProperty
   End
   Begin ComctlLib.ListView lvurl 
      Height          =   2775
      Left            =   2520
      TabIndex        =   9
      Top             =   120
      Width           =   4335
      _ExtentX        =   7646
      _ExtentY        =   4895
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      _Version        =   327682
      ForeColor       =   49152
      BackColor       =   0
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   2
      BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "Host"
         Object.Width           =   1411
      EndProperty
      BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         SubItemIndex    =   1
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "Url"
         Object.Width           =   4939
      EndProperty
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "URL"
      Height          =   255
      Left            =   2520
      TabIndex        =   1
      Top             =   3000
      Width           =   1695
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Caption"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   3000
      Width           =   1695
   End
End
Attribute VB_Name = "FrmAddCap"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdaddcap_Click()
rec.Open "select capblock.* from capblock where capblock.caption='" & txtcap.Text & "'", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 1 Then
rec.Close
MsgBox "Duplicate caption.", vbInformation + vbOKOnly, "Duplicate"
Else
rec.AddNew
lvcap.ListItems.Clear
rec(0) = txtcap.Text
rec.Update
rec.Close
gridcap
txtcap.Text = ""
End If
End Sub

Private Sub cmdaddu_Click()
rec.Open "select urlblock.* from urlblock where urlblock.url='" & txturl.Text & "'", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 1 Then
rec.Close
MsgBox "Duplicate Url.", vbInformation + vbOKOnly, "Duplicate"
Else
rec.AddNew
lvurl.ListItems.Clear
rec(0) = "127.0.0.1"
rec(1) = txturl.Text
rec.Update
rec.Close
gridurl
txturl.Text = ""
End If

End Sub

Private Sub cmddelu_Click()
rec.Open "select urlblock.* from urlblock where urlblock.url='" & txturl.Text & "'", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 0 Then
rec.Close
MsgBox "Url tidak di temukan.", vbInformation + vbOKOnly, "Not Found"
Else
lvurl.ListItems.Clear
rec.Delete
rec.Close
gridurl
End If
End Sub

Private Sub cmdedlcap_Click()
rec.Open "select capblock.* from capblock where capblock.caption='" & txtcap.Text & "'", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 0 Then
rec.Close
MsgBox "Caption tidak di temukan.", vbInformation + vbOKOnly, "Not Found"
Else
lvcap.ListItems.Clear
rec.Delete
rec.Close
gridcap
End If
End Sub

Private Sub gridcap()
rec.Open "capblock", conn, , adLockOptimistic
With rec
While Not .EOF
Set lstItem = lvcap.ListItems.Add(, , !Caption)
lstItem.SubItems(1) = !Caption

.MoveNext
Wend
End With
        rec.Close

End Sub
Private Sub gridurl()
rec.Open "urlblock", conn, , adLockOptimistic
With rec
While Not .EOF
Set lstItem = lvurl.ListItems.Add(, , !ip)
lstItem.SubItems(1) = !url
.MoveNext
Wend
End With
        rec.Close

End Sub


Private Sub Form_Load()
gridcap
gridurl
End Sub



Private Sub lvcap_Click()
txtcap.Text = lvcap.ListItems(lvcap.SelectedItem.Index).SubItems(1)
End Sub

Private Sub lvurl_Click()
txturl.Text = lvurl.ListItems(lvurl.SelectedItem.Index).SubItems(1)

End Sub

Private Sub txtcap_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdaddcap_Click
End If
End Sub

Private Sub txturl_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdaddu_Click
End If
End Sub
